Packages and data import
# packages
library(tidyverse)
library(janitor)
library(sf)
library(ggpomological)
library(tigris)
library(fiftystater)
library(mapview)
library(spdep)
# data
ca_schools <- st_read("../california_schools_pbe/CA_schools_PBE.shp") %>%
clean_names() # read in the California data
california_background <- fifty_states %>%
filter(id == "california") # make a background map of California
ca_tracts <- tigris::tracts(state = "CA")
ca_tracts_sf_transform <- ca_tracts %>% # start with tigris tracts data
st_as_sf() %>% # convert to sf
st_transform("+proj=longlat +datum=WGS84 +no_defs") # set coordinate reference system
# plot the school locations
ggplot() +
geom_polygon(data = california_background,
aes(x = long, y = lat, group = group),
fill = "#e68c7c") + # plot the basemap
geom_sf(data = ca_schools,
color = "#4f5157",
alpha = 0.6) + # add the schools point layer
coord_sf()
mapview(ca_schools)